﻿using System;
using System.Collections.Generic;

namespace blancetool
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Net.WebClient wc = new System.Net.WebClient();
            var type = args[0];
            string url = "";
            if (type == "btc")
            {
                url = "https://www.bitgo.com/api/v1/address/";
            }
            List<string> linex = new List<string>();
            var file = args[1];
            if (file.Contains("*"))
            {
                var filefilter = System.IO.Path.GetFileName(file);
                var path = System.IO.Path.GetDirectoryName(file);
                var fs = System.IO.Directory.GetFiles(path, filefilter, System.IO.SearchOption.AllDirectories);
                foreach(var f in fs)
                {
                    var lx = System.IO.File.ReadAllLines(f);
                    linex.AddRange(lx);
                }
            }
            else
            {
                var lx = System.IO.File.ReadAllLines(file);
                linex.AddRange(lx);
            }
            for (var i = 0; i < linex.Count; i++)
            {
                var addr = linex[i].Substring(0, 34);
                try
                {
                    var r = wc.DownloadString(url + addr);
                    Console.WriteLine(i.ToString("X04") + r);
                }
                catch
                {
                    Console.WriteLine("api 有限制，停一下");
                    System.Threading.Thread.Sleep(10000);
                    i--;
                    continue;
                }
                
             
                if (i % 50 == 0 && i > 0)
                {
                    Console.WriteLine("api 有限制，停一下");
                    System.Threading.Thread.Sleep(10000);
                }
            }
        }
    }
}
